import "reflect-metadata";

type MyMethodDecoratprType<T> = (
  targetClassPrototype: any,
  methodname: string,
  methodDecri: TypedPropertyDescriptor<T>
) => void;

export function get<T>(reqPath: string): MyMethodDecoratprType<T> {
  return function (targetClassPrototype, methodname, methodDecri) {
    // 将元数据定义在targetClassPrototype 的 methodname元数据上
    Reflect.defineMetadata("path", reqPath, targetClassPrototype, methodname);

    const methodParamTypeArr = Reflect.getMetadata(
      "design:paramtypes",
      targetClassPrototype,
      methodname
    );
    console.log("design:paramtypes:", methodParamTypeArr);

    const methodReturnTypeArr = Reflect.getMetadata(
      "design:returntype",
      targetClassPrototype,
      methodname
    );
    console.log("design:returntype:", methodReturnTypeArr);
  };
}
